package com.xsomnus.java_basic.juc.thread;

import java.util.concurrent.ThreadLocalRandom;

/**
 * @author 叶小夏
 * @since 2019-08-23 13:46
 */
public class KillSelfThread extends Thread {

    private int retryTimes;

    @Override
    public void run() {
        while (retryTimes ++ < 5 ) {
            System.out.println("【" + Thread.currentThread().getId() + "】Hi" + retryTimes);
            try {
                Thread.sleep(ThreadLocalRandom.current().nextInt(5000));
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    public static void main(String[] args) {
        KillSelfThread killSelfThread = new KillSelfThread();
        //killSelfThread.setDaemon(true);
        killSelfThread.start();
    }
}
